<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/7/15
 * Time: 21:53
 */

class DoctorPersonalController extends Controller
{

    /**
     * Method returning filters array.
     */
    public function filters()
    {
        return array(
            'accessControl',//Performs access control for CRUD operations
        );
    }

    /**
     * Defines User Access Level.
     */
    public function accessRules()
    {
        return array(
            array('allow',
                'actions' => array(),//Actions allowed
                'roles' => array('@'),//Roles allowed to perform actions
            ),
            array('deny',
                'actions' => array(),//Actions not allowed
                'roles' => array('*'),//Roles not allowed to perform actions
            ),
        );
    }

    /**
     * Declares class-based actions.
     */
    public function actions()
    {
        return array(
            // captcha action renders the CAPTCHA image displayed on the contact page
            'captcha' => array(
                'class' => 'CCaptchaAction',
                'height' => 37,
                'minLength' => 4,
                'maxLength' => 6,
                'backColor' => 0xFFFFFF,
            ),
            // page action renders "static" pages stored under 'protected/views/site/pages'
            // They can be accessed via: index.php?r=site/page&view=FileName
            'page' => array(
                'class' => 'CViewAction',
            ),
        );
    }

    /******************************************************************************************
     * Following functions are related to doctor or delegate information and qualification
     ******************************************************************************************/

    /**
     * Get User Information
     * @param bigin $pk_doctor_id
     */
    public function actionGetInformation($pk_doctor_id){
        if(isset(Yii::app()->session['status']) && Yii::app()->session['status'] == 'logged') {
            $doctorInformation = TblDoctorInformation::model()->findByAttributes(array('pk_fk_doctor_id'=>$pk_doctor_id));
            $this->render('information',array('doctorInformation'=>$doctorInformation));
        }
        else
            $this->redirect(array('site/login'));// View redirection
    }

    /**
     * Get user Qualification
     * @param bigint $pk_doctor_id
     */
    public function actionGetQualification($pk_doctor_id){
        if(isset(Yii::app()->session['status']) && Yii::app()->session['status'] == 'logged') {
            $doctorInformation = TblDoctorInformation::model()->findByAttributes(array('pk_fk_doctor_id'=>$pk_doctor_id));
            $this->render('qualification',array('doctorInformation'=>$doctorInformation));
        }
        else
            $this->redirect(array('site/login'));// View redirection
    }

}